<!-- 消息详情 -->
<template>
	<view class="page">
		<view style=" background-color: #fff; padding: 20rpx; border-radius: 10rpx;">
			<view class="content">
				{{ messageDetail && messageDetail.title? messageDetail.title : '--' }}
			</view>
			<view class="text">
				<text>发布人：</text>
				<text>{{ messageDetail && messageDetail.handlerId_dictText? messageDetail.handlerId_dictText : '--' }}</text>
			</view>
			<view class="time">
				<text>发布时间：</text>
				<text>{{ messageDetail && messageDetail.publishTime? messageDetail.publishTime : '--' }}</text>
			</view>
			<view class="time">
				<text>发布类别：</text>
				<text>{{ messageDetail && messageDetail.noticeCategory_dictText? messageDetail.noticeCategory_dictText : '--' }}</text>
			</view>
			<view class="time" style="margin-bottom: 32rpx;">
				<text>发文密级：</text>
				<text>{{ messageDetail && messageDetail.intensiveType_dictText? messageDetail.intensiveType_dictText : '--' }}</text>
			</view>
			<view class="parase">
				<u-parse style="white-space: break-word !important;word-break: break-all !important;" :content="messageDetail.content"></u-parse>
			</view>
		</view>
		<view v-if="messageDetail.attachments" style=" background-color: #fff; padding: 20rpx; border-radius: 10rpx; margin-top: 20rpx;">
			<view class="text">附件信息:</view>
			<!-- <fileList :fileList="messageDetail.attachments"></fileList> -->
			<view style="color: #2b85e4;" v-for="(item, index) in attachmentsComp" :key="index" @click="showFile(item)">{{item}}</view>
		</view>
		<view class="space-x-1 px-1 btn_position"  style="left: 0;">
			<u-button type="primary" :plain="true" text="签发意见" @click="seeIssuingOpinions" v-if="$hasPerm('publishNoticeHiddenBtn')"></u-button>
			<u-button type="primary" text="去签发" @click="goIssue" v-if="progress"></u-button>
		</view>
		<view style="height: 100rpx"></view>
	</view>
</template>

<script>
	import { mapState } from 'vuex'
	import fileList from '../synergy/components/fileList.vue'
	import {imageUrl} from '@/utils/common.js'
	import http from '@/utils/request'
	import {BASE_URL, ONLINE_BASE_URL} from '@/utils/baseUrl.js';
	export default {
		data() {
			return {
				id: '', // 详情id
				progress: '', // 是否签发
				messageDetail: {}, // 消息详情
				imageUrl: imageUrl
			}
		},
		components: {
			fileList
		},
		onLoad(options) {
			this.id = options.id || ''
			this.progress = options.progress || ''
			this.detail(this.id)
			this.getRead() // 获取消息详情已读
		},
		computed: {
			attachmentsComp(){
				let list = []
				if(this.messageDetail.attachments){
					list = this.messageDetail.attachments.split(',')
				}
				return list
			}
		},
		onShow() {
			// 清空选择通知公告选择的人员
			if (this.$store.state.selectPerson) {
				this.$store.dispatch('actionsSetSelectPerson', '')
			}
		},
		methods: {
			...mapState(['userInfo']),
			async detail(id) {
				// 获取详情
				http.get('/api/erp/publishNotice/queryPageById', { id }).then(res => {
					if (res.success) {
						this.messageDetail = res.result.records[0]
					}
				})
			},
			getRead () {
				var params = {
					empId: this.userInfo().empId,
					noticeId: this.id
				}
				http.get('/api/erp/publishNotice/read', params).then(res => {
					if (res.success) {
						// 阅读成功
					}
				})
			},
			// 签发意见
			seeIssuingOpinions () {
				uni.navigateTo({
					url: `/pages/message/seeIssuingnoticesList?id=${this.id}`
				})
			},
			// 去签发
			goIssue () {
				uni.navigateTo({
					url: `/pages/message/noticeIssueForm?id=${this.id}&intensiveType=${this.messageDetail.intensiveType}`
				})
			},
			// 点击预览
			showFile (item) {
				let text = `${this.userInfo().orgCodeTxt}-${this.userInfo().realname}-${this.userInfo().workNo}`
				let url = BASE_URL + '/api/erpmng/sys/common/static/' + item
				uni.navigateTo({
				  url: `/pages/previewFile/previewFile?url=${encodeURIComponent(url)}&watermarkTxt=${text}`,
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import url('@/assets/inputStyle.scss');
	page{
		// background-color: #FFFFFF;
	}
.page{
	// padding: 20rpx;
	.content{
		text-align: center;
		font-size: 16px;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 600;
		color: #171717;
		// margin-top: 30rpx;
	}
	.text{
		margin-top: 32rpx;
		font-size: 14px;
		font-family: PingFangSC-Light, PingFang SC;
		font-weight: 300;
		color: #7F7F7F;
	}
	.time{
		margin: 8rpx 0 8rpx 0;
		font-size: 14px;
		font-family: PingFangSC-Light, PingFang SC;
		font-weight: 300;
		color: #7F7F7F;
	}
	.parase{
		white-space: normal;
	}
}
</style>
